package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import com.eastfair.database.mybatis.typehandler.M9EncryptHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 退款申请
 * </p>
 *
 * @author gj
 * @since 2022-06-21
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "pay_apply_refund", autoResultMap = true)
@ApiModel(value = "ApplyRefund", description = "退款申请")
@AllArgsConstructor
public class ApplyRefund extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 客户id
     */
    @ApiModelProperty(value = "客户id")
    @TableField(value = "cutomer_id")
    @Excel(name = "客户id")
    private Long cutomerId;

    /**
     * 客户名称
     */
    @ApiModelProperty(value = "客户名称")
    @Size(max = 255, message = "客户名称长度不能超过255")
    @TableField(value = "cutomer_name", condition = LIKE)
    @Excel(name = "客户名称")
    private String cutomerName;

    /**
     * 申请退款金额
     */
    @ApiModelProperty(value = "申请退款金额")
    @TableField(value = "refund_apply_amount")
    @Excel(name = "申请退款金额")
    private BigDecimal refundApplyAmount;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @TableField(value = "exhibition_id")
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @TableField(value = "exhibition_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 对方户名
     */
    @ApiModelProperty(value = "对方户名")
    @Size(max = 255, message = "对方户名长度不能超过255")
    @TableField(value = "bank_account_name", condition = LIKE)
    @Excel(name = "对方户名")
    private String bankAccountName;

    /**
     * 对方账号
     */
    @ApiModelProperty(value = "对方账号")
    @Size(max = 255, message = "对方账号长度不能超过255")
    @TableField(value = "bank_account_num", condition = LIKE)
    @Excel(name = "对方账号")
    private String bankAccountNum;

    /**
     * 对方开户行
     */
    @ApiModelProperty(value = "对方开户行")
    @Size(max = 255, message = "对方开户行长度不能超过255")
    @TableField(value = "bank_name", condition = LIKE)
    @Excel(name = "对方开户行")
    private String bankName;

    /**
     * 退款方式（数据字典） PUBLIC_TO_PUBLIC 公对公转账 ONLINE 在线退款 OFFLINE 线下退款
     */
    @ApiModelProperty(value = "退款方式（数据字典）")
    @Size(max = 255, message = "退款方式（数据字典）长度不能超过255")
    @TableField(value = "refund_type", condition = LIKE)
    @Excel(name = "退款方式（数据字典）")
    private String refundType;

    /**
     * 申请人id
     */
    @ApiModelProperty(value = "申请人id")
    @TableField(value = "applicant_id")
    @Excel(name = "申请人id")
    private Long applicantId;

    /**
     * 申请人姓名
     */
    @ApiModelProperty(value = "申请人姓名")
    @Size(max = 255, message = "申请人姓名长度不能超过255")
    @TableField(value = "applicant_name", condition = LIKE)
    @Excel(name = "申请人姓名")
    private String applicantName;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Size(max = 255, message = "备注长度不能超过255")
    @TableField(value = "remart", condition = LIKE)
    @Excel(name = "备注")
    private String remart;

    /**
     * 退款时间
     */
    @ApiModelProperty(value = "退款时间")
    @TableField(value = "refund_time")
    @Excel(name = "退款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime refundTime;

    /**
     * 退款状态   0 未退款  1 已退款 2 退款中 （支付系统使用，业务系统使用审核状态）
     */
    @ApiModelProperty(value = "退款状态   0 未退款  1 已退款 2 退款中")
    @TableField(value = "refund_state")
    @Excel(name = "退款状态   0 未退款  1 已退款 2 退款中")
    private Integer refundState;

    /**
     * 系统code
     */
    @ApiModelProperty(value = "系统code")
    @Size(max = 20, message = "系统code长度不能超过20")
    @TableField(value = "system_code", condition = LIKE)
    @Excel(name = "系统code")
    private String systemCode;

    /**
     * 业务id(结算单)
     */
    @ApiModelProperty(value = "业务id(结算单)")
    @TableField(value = "business_id")
    @Excel(name = "业务id(结算单)")
    private Long businessId;

    /**
     * 结算类型
     * {@link com.eastfair.pay.enums.ApplyRefundBusinessTypeEnum}
     */
    @ApiModelProperty(value = "结算类型")
    @TableField(value = "business_type")
    @Excel(name = "结算类型")
    private String businessType;

    /**
     * 退款人
     */
    @ApiModelProperty(value = "退款人")
    @Size(max = 255, message = "退款人长度不能超过255")
    @TableField(value = "refund_user_name", condition = LIKE)
    @Excel(name = "退款人")
    private String refundUserName;

    /**
     * 单号
     */
    @ApiModelProperty(value = "单号")
    @Size(max = 255, message = "单号长度不能超过255")
    @TableField(value = "business_num", condition = LIKE)
    @Excel(name = "单号")
    private String businessNum;

    /**
     * 退款人
     */
    @ApiModelProperty(value = "退款人联系方式")
    @Size(max = 255, message = "退款人联系方式长度不能超过255")
    @TableField(value = "applicant_concat", condition = LIKE, typeHandler = M9EncryptHandler.class)
    @Excel(name = "退款人联系方式")
    private String applicantConcat;


    /**
     * 实际退款金额
     */
    @ApiModelProperty(value = "实际退款金额")
    @TableField(value = "refund_amount")
    @Excel(name = "实际退款金额")
    private BigDecimal refundAmount;


    /**
     * 审核状态
     */
    @ApiModelProperty(value = "审核状态")
    @Size(max = 255, message = "审核状态长度不能超过255")
    @TableField(value = "examine_state", condition = LIKE)
    @Excel(name = "审核状态")
    private String examineState;

    /**
     * 审核人
     */
    @ApiModelProperty(value = "审核人")
    @Size(max = 255, message = "审核人长度不能超过255")
    @TableField(value = "examiner", condition = LIKE)
    @Excel(name = "审核人")
    private String examiner;

    /**
     * 审核意见
     */
    @ApiModelProperty(value = "审核意见")
    @Size(max = 255, message = "审核意见长度不能超过255")
    @TableField(value = "examine_reason", condition = LIKE)
    @Excel(name = "审核意见")
    private String examineReason;

    /**
     * 审核人id
     */
    @ApiModelProperty(value = "审核人id")
    @TableField(value = "examine_id")
    @Excel(name = "审核人id")
    private Long examineId;


    /**
     * 退款类型
     * {@link com.eastfair.pay.enums.RefundClassifyEnum}
     */
    @ApiModelProperty(value = "退款类型")
    @Size(max = 255, message = "退款类型长度不能超过255")
    @TableField(value = "refund_classify", condition = LIKE)
    @Excel(name = "退款类型")
    private String refundClassify;

    /**
     * 收款商户名
     */
    @ApiModelProperty(value = "收款商户名")
    @Size(max = 255, message = "收款商户名长度不能超过255")
    @TableField(value = "merchant_name", condition = LIKE)
    @Excel(name = "收款商户名")
    private String merchantName;

    /**
     * 商户名id
     */
    @ApiModelProperty(value = "商户名id")
    @TableField(value = "merchant_id")
    @Excel(name = "商户名id")
    private Long merchantId;

    /**
     * 退款单号
     */
    @ApiModelProperty(value = "退款流水号")
    @Size(max = 255, message = "退款流水号长度不能超过255")
    @TableField(value = "refund_num", condition = LIKE)
    @Excel(name = "退款流水号")
    private String refundNum;

    /**
     * 交易订单交易流水号
     */
    @ApiModelProperty(value = "交易订单交易流水号")
    @Size(max = 255, message = "交易订单交易流水号长度不能超过255")
    @TableField(value = "pay_order_no", condition = LIKE)
    @Excel(name = "交易订单交易流水号")
    private String payOrderNo;

    /**
     * 收款账户开户行
     */
    @ApiModelProperty(value = "收款账户开户行")
    @Size(max = 255, message = "收款账户开户行长度不能超过255")
    @TableField(value = "merchant_bank", condition = LIKE)
    @Excel(name = "收款账户开户行")
    private String merchantBank;

    /**
     * 收款账户银行卡号
     */
    @ApiModelProperty(value = "收款账户银行卡号")
    @Size(max = 255, message = "收款账户银行卡号长度不能超过255")
    @TableField(value = "merchant_bank_num", condition = LIKE)
    @Excel(name = "收款账户银行卡号")
    private String merchantBankNum;
    /**
     * 荆艺申请流水
     */
    @ApiModelProperty(value = "荆艺退款申请流水")
    @TableField(value = "mainno", condition = LIKE)
    private String mainno;


    @Builder
    public ApplyRefund(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime,
                       Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId,
                       Long cutomerId, String cutomerName, BigDecimal refundApplyAmount, Long exhibitionId, String exhibitionName, String bankAccountName,
                       String bankAccountNum, String bankName, String refundType, Long applicantId, String applicantName, String remart,
                       LocalDateTime refundTime, Integer refundState, String systemCode, Long businessId, String businessType, String refundUserName, BigDecimal refundAmount) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.cutomerId = cutomerId;
        this.cutomerName = cutomerName;
        this.refundApplyAmount = refundApplyAmount;
        this.exhibitionId = exhibitionId;
        this.exhibitionName = exhibitionName;
        this.bankAccountName = bankAccountName;
        this.bankAccountNum = bankAccountNum;
        this.bankName = bankName;
        this.refundType = refundType;
        this.applicantId = applicantId;
        this.applicantName = applicantName;
        this.remart = remart;
        this.refundTime = refundTime;
        this.refundState = refundState;
        this.systemCode = systemCode;
        this.businessId = businessId;
        this.businessType = businessType;
        this.refundUserName = refundUserName;
        this.refundAmount = refundAmount;
    }

}
